import type { EChartsReactProps } from 'echarts-for-react'
import EChartsReactCore from 'echarts-for-react/lib/core'
import * as echarts from 'echarts/core'
import { CanvasRenderer } from 'echarts/renderers'

/** 👇 采用按需引入, 需要什么组件自己引入; 全局创建一个 echarts 实例即可 👇 */
echarts.use([CanvasRenderer])

export default function ReactECharts(props: Omit<EChartsReactProps, 'echarts'>) {
  return (
    <EChartsReactCore
      notMerge
      lazyUpdate
      {...props}
      echarts={echarts}
      opts={{ renderer: 'canvas', ...props.opts }}
    />
  )
}
